package cn.itcast.n6;

import java.util.ArrayList;
import java.util.List;
public class test1 {
    static List<Double>TS1=new ArrayList<Double>();//存放默尼森数
    public static void main(String[] args) {
        int p = 2;
        int c =6;//默尼森数个数
        while(c>0){
            double m=0;
            if(show(p)&&show((Math.pow(2,p)-1)))
            {TS1.add(Math.pow(2, p)-1);c--;}
            p++;
        }
        System.out.print("默尼森数有：");
        for(Double x1:TS1){
            System.out.print(x1+" ");}
    }
    //判断函数
    public static boolean show(double n){
        if(n==2||n==3)return true;
        int t=0;
        for(int i=2;(i*i)<=n;i++){
            if(n%i==0)t++;
        }
        if(t==0)return true;
        else return false;
    }
}
